<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="../template.xhtml">
	<ui:define name="content">
		<rich:panel >
			<f:facet name="header">
				<h:outputText value="Discount edit" />
			</f:facet>
			<h:form>
		    	<h:panelGrid columns="3">
		    	
		    	    <h:outputText value="Stock Type:" />
		    	    <rich:select id="stockType"
		    	        converter="#{stockTypeConverter}" required="true"
						value="#{discountsEditorBean.stockType}"
						requiredMessage="Stock Type is required">
						<f:selectItems value="#{stockTypesBean.stockTypes}"
							var="stockType" itemLabel="#{stockType.name}"
							itemValue="#{stockType}" itemValueAsString="#{stockType.id}" />
					</rich:select>
					<rich:message for="stockType" />
					
					
		    	
					<h:outputText value="Time:" />
					<h:inputText id="time" required="true"
						value="#{discountsEditorBean.time}"
						requiredMessage="Time is required."
						validatorMessage="Time must be a number" label="Time">
						<f:validateLongRange minimum="1" />
					</h:inputText>
					<rich:message for="time" />

                    
					<h:outputText value="Discount:" />
					<h:inputText id="discountValue" required="true"
						value="#{discountsEditorBean.discountValue}"
						requiredMessage="Discount is required."
						validatorMessage="Discount must be a number" label="Discount">
						<f:validateLongRange minimum="1" />
					</h:inputText>
					<rich:message for="discountValue" />
					
					<h:outputText value="Discount Type:" />
					<rich:select id="discountType" required="true"
						value="#{discountsEditorBean.discountType}"
						requiredMessage="Discount Type is required">
                		<f:selectItem itemValue="PERCENTAGE" itemLabel="PERCENTAGE" />
                		<f:selectItem itemValue="PRICE" itemLabel="PRICE" />
            		</rich:select>
					<rich:message for="discountType" />
					

					<f:facet name="footer">
						<h:commandButton action="#{discountsEditorBean.submit}" value="Store" />
						<h:commandButton action="back" value="Cancel" immediate="true" />
					</f:facet>
				</h:panelGrid>

			</h:form>
		</rich:panel>
	</ui:define>
</ui:composition>
</html>